package com.distribution.common.web.response;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author test
 * @date 2022年01月04日 12:06
 */
public class ResponseUtils {

    public static void send(HttpServletResponse response, ResponseResult result) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        ServletOutputStream out = response.getOutputStream();
        ObjectMapper objectMapper = new ObjectMapper();
        out.write(objectMapper.writeValueAsString(result).getBytes("UTF-8"));
        out.flush();
        out.close();
    }

}
